package tmi.li.txwthrsmall;


import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

public class TxWthrSmallReceiver extends BroadcastReceiver{
	static String TAG = "tmi.li.txwthrsmall.TxWthrReceiver";
	
	@Override
    public void onReceive(Context context, Intent intent) {
		
		//getting the Broadcast Action to verify the intent Actions
        String action = intent.getAction();

        if (action.equals(Intent.ACTION_BOOT_COMPLETED) 
        	|| action.equals(Intent.ACTION_SCREEN_ON) 
        	|| action.equals(TxWthrSmallFinals.UPDATE)    ) {
        	
        	//get the app widgetmanager instance
            AppWidgetManager gm = AppWidgetManager.getInstance(context);
            
            int[] appWidgetIds = gm.getAppWidgetIds(new ComponentName(TxWthrSmallFinals.PACKAGE_NAME, TxWthrSmallFinals.WIDGET_CLASS_PATH));
            
            for(int i = 0; i < appWidgetIds.length; i++) {
            	TxWthrSmallProvider.updateWidget(context, gm,  appWidgetIds[i]);
            }
        }
    }
}